SpringBoot 您所在的位置:网站首页 quartzdate mode SpringBoot

SpringBoot

#SpringBoot| 来源: 网络整理| 查看: 265

关注微信技术公众号:CodingTechWork,一起学习进步。 引言

  一般在使用定时任务时,我们首先会想到使用@Scheduled注解去给某个任务设置定时时间进行定时执行。当定时任务过多时,或者有增删改查需求时,@Scheduled注解将无法满足我们的需求。本文一起学习总结Quartz定时框架的使用。

Quartz介绍 概述

Quartz is a richly featured, open source job scheduling library that can be integrated within virtually any Java application - from the smallest stand-alone application to the largest e-commerce system. Quartz can be used to create simple or complex schedules for executing tens, hundreds, or even tens-of-thousands of jobs; jobs whose tasks are defined as standard Java components that may execute virtually anything you may program them to do. The Quartz Scheduler includes many enterprise-class features, such as support for JTA transactions and clustering. Quartz is freely usable, licensed under the Apache 2.0 license.

  Quartz是OpenSymphony开源的一个项目,是一个由Java编写的开源作业调度框架。

特点 支持分布式高可用,我们需要某个定时任务在多个节点中只有某个节点可以执行时,就需要Quartz来实现,否则使用@Scheduled等方式会造成所有节点都执行一遍。 支持持久化,Quartz有专门的数据表来实现定时任务的持久化。 支持多任务调度和管理,Quartz可以在数据库中存储多个定时任务进行作业调度,可以实现定时任务的增删改查等管理。 组成

  Quartz由三部分组成:

任务:JobDetail 触发器:Trigger(分为SimpleTrigger和CronTrigger) 调度器:Scheduler JobDetail

  JobDetail主要由JobKey(job的名字name和分组group)、JobClass、JobDataMap(任务相关的数据)、JobBuilder组成。常用的是前几个。 JobDetail源码

package org.quartz; import java.io.Serializable; public interface JobDetail extends Serializable, Cloneable { JobKey getKey(); String getDescription(); Class


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有